#include <stdio.h>
#include <stdlib.h>

typedef struct LNode
{
    int data;
	struct LNode *next;
}LNode;

int main()
{
    LNode *table;
	int data = 0;
	table = (LNode *)malloc(sizeof(LNode));

	if(table == NULL)
	{
	    return 0;
	}

	LNode *tail = table;
	printf("请输入，9999结束\n");
	scanf("%d", &data);
	while(1)
	{
	    if(data == 9999)
		{
		    break;
		}

		LNode *Node = (LNode *)malloc(sizeof(LNode));
		Node->data = data;
		tail->next = Node;
		tail = Node;

	    scanf("%d", &data);
	}

	tail->next = table;
//-----------输出----------------
	LNode *Node = table->next;
	while(Node != table)
	{
	    printf("%d  ", Node->data);
	    Node = Node->next;
	}
	
	printf("\n");
	return 0;
}
